package org.eliza.base.basicx.oop.oc


/*-*- coding:utf-8 -*-
* @Author  : ygree 
* @Time    : 2021/7/2 2:46
* @Software : IntelliJ IDEA
*/

private class Basic {
    interface MyInterface {
        val time: Int
        fun bar()  //需要继承初始化
    }

    // 一个类或者对象可以实现一个或多个接口。
    class Child(override val time: Int) : MyInterface {
        override fun bar() {
            println("Child bar: ${time}")
        }
    }

    class Child2(override val time: Int) : MyInterface {
        override fun bar() {
            println("Child2 bar: ${time}")
        }
    }

    fun Show(vararg iss: MyInterface) {
        iss.forEach {
            it.bar()
        }
    }
}

private fun main() {
    val c = Basic.Child(1)
    val c2 = Basic.Child2(2)
    Basic().Show(c, c2)
}
